<%--
  Created by IntelliJ IDEA.
  User: Eternity
  Date: 2020/8/18
  Time: 11:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>登录</title>
    <link rel="stylesheet" href="static/bootstrap-4.1.3-dist/css/bootstrap.css"/>
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>

    <!-- bootstrap.bundle.min.js 用于弹窗、提示、下拉菜单，包含了 popper.min.js -->
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>

    <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="static/js/jquery-2.1.0.js"></script>
    <script type="text/javascript">
        /*验证码ajax*/
        $(function () {
            $("#code").click(function () {
                $.ajax({
                    type:"post",
                    url:"/user/code",
                    data:"name=John&location=Boston",
                    success:function (msg) {
                        $("#code").attr("src","/user/code");

                    }

                })
            })
        })

        function subBtn() {

            //获取表单信息
            var names = $("#names").val()
            var stuNum = $("#stuNum").val()
            var username = $("#username").val()
            var password = $("#password").val()
            var type = 1

            if (names == null || names == ""){
                alert("姓名不能为空！")
                return false;
            }
            if (stuNum == ""){
                alert("学籍号不能为空！")
                return false;
            }
            if (username == null || username == ""){
                alert("账号不能为空！")
                return false;
            }
            if (password == null || password == ""){
                alert("密码不能为空！")
                return false;
            }

            $.ajax({
                //请求路径
                url : "/user/addUser",
                //请求参数
                data:{
                    names : names,
                    username : username,
                    stuNum : stuNum,
                    password : password,
                    type : type
                },
                type:"post",
                dataType:"json",
                success:function (data) {
                    alert(data.msg)
                    //刷新页面
                    window.location.reload();
                },error:function () {
                    alert("系统异常！")
                }
            })
        }

        // function next() {
        //     window.location="index1.html";
        // }

    </script>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        body{
            background:url("static/js/imges/36.gif" );
            background-size: 100% 100%;

        }
        .container_title{
            width:530px;
            height:500px;
            background:#0b0c4c;
            background-color: rgba(0,0,0,0.3);
            margin:0 auto;
            margin-top: 140px;
            border-radius: 35px;
            box-shadow: 10px 10px 10px #1d2124;
        }
        .container h1{
            color: #fff;
            padding-top: 20px;
            font-family: 幼圆;
            font-weight: bold;

        }
        .form-control{
            width:370px;
            height:47px;
            border-radius: 50px;
            margin-top: 36px;
            margin-left:50px;
            border: 1px solid deepskyblue;

        }
        .form-check-label{
            color:#fff;
            margin-left: 60px;
            margin-top: 10px;
        }

        button{
            width:250px;
            height:40px;
            margin-left: 100px;
            margin-top: 15px;
            background: #fff;
        }
        button a{
            color:#fff;
        }
        #code{
            margin-left: 300px;
            margin-top: -42px;
        }

    </style>
</head>
<body>

<div class="container_title">
    <div class="container">
        <h1 align="center">欢迎登录</h1>
        <form action="user/login" method="post">
            <div class="form-group">
                <input type="text" class="form-control" name="username" id="username1" placeholder="请输入账号">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" name="password" id="password1" placeholder="请输入密码">
            </div>
            <div class="form-group">
                <input type="text" style="width:250px;height: 45px" class="form-control" name="code"  placeholder="请输入您的验证码">
                <img src="/user/code" id="code">
            </div>

            <a href="index3.jsp" style="display: block;color: red;margin-left: 330px">忘记密码</a>
            <button type="submit" class="btn btn-success">登录</button>
            <button type="button" class="btn btn-success"  data-toggle="modal" data-target="#myModal">注册</button>
        </form>
        <p>${msg}</p>
    </div>

    <<!-- 添加模态框 -->
    <div class="modal fade" id="myModal">
        <div class="modal-dialog">
            <div class="modal-content">

                <!-- 模态框头部 -->
                <div class="modal-header">
                    <h4 class="modal-title">添加用户信息</h4>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <%--<form action="${pageContext.request.contextPath}/account/addAccount" method="post">--%>
                <!-- 模态框主体 -->
                <div class="modal-body">

                    <div class="form-group">
                        <%--<label for="names">姓名:</label>--%>
                        <input type="text" class="form-control" id="names" name="names" placeholder="请输入用户名">
                    </div>
                    <div class="form-group">
                        <%--<label for="stuNum">学籍号:</label>--%>
                        <input type="text" class="form-control" id="stuNum" name="stuNum" placeholder="请输入学籍号">
                    </div>
                    <div class="form-group">
                        <%--<label for="username">账号:</label>--%>
                        <input type="text" class="form-control" id="username" name="username" placeholder="请输入账号">
                    </div>
                    <div class="form-group">
                        <%--<label for="pwd1">密码:</label>--%>
                        <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
                    </div>
                </div>
                <!-- 模态框底部 -->
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" onclick="subBtn()">保存</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                </div>
                <%--</form>--%>

            </div>
        </div>
    </div>
</div>


</div>
</body>
</html>
